function isEmpty(value)
{
    var result=false;
    if ('' == value || null == value)
    {
        result=true;
    }
    return result;
}

function inRange(value, lowerLimit, upperLimit)
{
    var result=true;
    var number=parseInt(value, 10);
    if (lowerLimit > number || upperLimit < number)
    {
        result=false;
    }
    return result;
}

function isLeapYear(year)
{
    var result=false;
    if (0 == year%4)
    {
        if (0 == year%100)
        {
            if (0 == year%400)
            {
                result=true;
            }
        }
        else
        {
            result=true;
        }
    }
    return result;
}

function validateYear(year)
{
    var result=false;
    if (!isEmpty(year))
    {
        if (inRange(year, 2009, 2012))
        {
            result=true;
        }
    }
    return result;
}

function validateMonth(month)
{
    var result=false;
    if (!isEmpty(month))
    {
        if (inRange(month, 1, 12))
        {
            result=true;
        }
    }
    return result;
}

function validateDay(day, lowerLimit, upperLimit)
{
    var result=false;
    if (!isEmpty(day))
    {
        if (inRange(day, lowerLimit, upperLimit))
        {
            result=true;
        }
    }
    return result;
}

function validateDate(year, month, day)
{
    var result=false;
    year=parseInt(year, 10);
    month=parseInt(month, 10);
    day=parseInt(day, 10);
    if (validateYear(year))
    {
        if (validateMonth(month))
        {
            var maxDayMonth=new Array(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
            if (isLeapYear(year))
            {
                maxDayMonth[2]=29;
            }
            if (validateDay(day, 1, maxDayMonth[month]))
            {
                result=true;
            }
        }
    }
    return result;
}